<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/8
 * Time: 8:30
 */
//1. 不设置有效期：就是会话Cookies
//setcookie('abc','110');

//2. 设置有效期
//setcookie('abc','110',time()+24*3600);



$userName = $_POST['uesrname'];
$password = $_POST['password'];
$arr = [
    '123456789a'=>[
        $userName => 'admin' ,
        $password=>'123456'
    ],
    '123456789b'=>[
        $userName => 'test' ,
        $password=>'666666'
    ],
    '123456789c'=>[
        $userName => 'zhangsan' ,
        $password=>'888888'
    ]
];
if(!empty($userName) && !empty($password)){
    echo '登入成功';
    echo '<br />';

    if($userName == 'admin' && $password=='123456'){
        setcookie('Token','12346789a',time()+24*3600);
    }else if($userName == 'test' && $password=='666666'){
        setcookie('Token','123456789b',time()+24*3600);
    }else if($userName == 'zhangsan' && $password=='888888'){
        setcookie('Token','123456789c',time()+24*3600);
    }
    echo '<a href="user.php">进入个人中心</a>';
}else{
    echo '用户名或密码错误';
}


